<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>37.diffing</title>
</head>

<body>
    <!-- 准备好一个容器 -->
    <div id="app"></div>
    <!-- 引入react核心库 -->
    <script type="text/javascript" src="../js2/react.development.js"></script>
    <!-- 引入react-dom 用于支持 react 操作 dom -->
    <script type="text/javascript" src="../js2/react-dom.development.js"></script>
    <!-- 引入 label，用于将 jsx 转化为 js -->
    <script type="text/javascript" src="../js/babel.min.js"></script>
    <!-- 引入 prop-types，用于对于组件标签属性进行限制 -->
    <script type="text/javascript" src="../js/prop-types.js"></script>


    <!-- 此处必须写 text/babel -->
    <script type="text/babel">

        // 创建组件
        class Time extends React.Component {

            state = { date: new Date() }

            componentDidMount() {
                setInterval(() => {
                    this.setState({
                        date: new Date()
                    })
                }, 1000)
            }

            // 初始化渲染，页面更新时候调用
            render() {
                return (
                    <div>
                        <h1>你好</h1>
                        <input type="text" />
                        <span>
                            现在是：{this.state.date.toTimeString()}
                            <input type="text" />
                        </span>
                    </div>
                )
            }
        }

        // 渲染组件
        ReactDOM.render(<Time />, document.getElementById("app"))
    </script>

</body>

</html>